package com.yunxi.service.dubboService.impl.sys;

import com.github.pagehelper.PageInfo;
import com.yunxi.model.sys.Country;
import com.yunxi.service.localService.sys.CountryService;
import com.yunxi.sys.pojo.CountryVO;
import com.yunxi.sys.service.CountryDubboService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import java.lang.reflect.InvocationTargetException;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 
 * @since 2019-05-21
 */
public class CountryDubboServiceImpl implements CountryDubboService {

    @Autowired
    @Qualifier(value = "countryServiceImpl")
    CountryService countryService;


    @Override
    public CountryVO getById(String id) throws InvocationTargetException, IllegalAccessException {
    Country country = countryService.getById(id);
    CountryVO countryVO = new CountryVO();
        BeanUtils.copyProperties(country,countryVO);
        return countryVO;
    }

    @Override
    public void saveOrUpdate(CountryVO countryVO) throws InvocationTargetException, IllegalAccessException {
    Country country = new Country();
        BeanUtils.copyProperties(countryVO,country);
    countryService.saveOrUpdate(country);
    }

    @Override
    public void removeById(String id) {
    countryService.removeById(id);
    }

    @Override
    public PageInfo<CountryVO> findPageByVO(CountryVO countryVO, Integer pageNum, Integer pageSize) throws InvocationTargetException, IllegalAccessException {

      PageInfo<CountryVO> pageInfo = countryService.pageByVo(countryVO,pageNum,pageSize);

      return pageInfo;

   }

    @Override
    public void removeByList(List<CountryVO> countryVOList) throws IllegalAccessException, InvocationTargetException, InstantiationException {
        countryService.removeByListVo(countryVOList);
    }

    @Override
    public List listByVO(CountryVO countryVO) {
        return countryService.listByVo(countryVO);
    }
}
